using System;

namespace sql_train
{
    public class DataAnswer : Answer
    {
        public DataAnswer(SimpleDataTable data)
        {
            Data = data;
        }

        public SimpleDataTable Data { get; private set; }

        public override VerificationResult Verify(Answer answer)
        {
            return new VerificationResult(Equals(answer));
        }

        public bool Equals(DataAnswer other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return Equals(other.Data, Data);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (DataAnswer)) return false;
            return Equals((DataAnswer) obj);
        }

        public override int GetHashCode()
        {
            return (Data != null ? Data.GetHashCode() : 0);
        }
    }
}